<?php
namespace app\admin\controller;
use app\admin\controller\Base;
use app\common\model\SystemSet;
use think\Db;

class Index extends Base
{
	public function _initialize()
	{
		parent::_initialize();
	}
	
	public function index()

	{
		return $this->fetch();
	}
	
	public function aa(){
		
		return $this->fetch();
	}

	public function actual_info(){
		$ret = ['sh'=>0,'zx'=>0,'fy'=>0];
		$ret['zx'] = Db::name('username')->where(['current_from'=>['>',0]])->count();
		$ret['sh'] = Db::name('chongzhi_list')->where(['zt'=>0,'czadmin'=>' '])->count();
		$users = Db::name('username')->where('nbzh',1)->column('username');
		$uus = implode(',', $users);
		$ret['fy'] = Db::name('agent_balance')->group("agent,FROM_UNIXTIME(add_time,'%Y-%m-%d')")->field("FROM_UNIXTIME(add_time,'%Y-%m-%d') as in_time,sum(balance) as total,agent,status")->where('balance','>',0)->where('status',0)->where('agent','not in',$uus)->order("FROM_UNIXTIME(add_time,'%Y-%m-%d') DESC")->count();
		return json_encode($ret,JSON_UNESCAPED_UNICODE);

	}

	public function warning(){

		$systemSet = new SystemSet();
		$mic_xx = $systemSet->dLists('xt_tishi_msic');
		$xxmic='';
		$xsmic='';
		$txmic='';
		$dlmic='';

		$xxcz_class = 0;
		$xscz_class = 0;
		$tx_class = 0;
		$dl_class = 0;

		$xxcz_video = '';
		$xscz_video = '';
		$tx_video = '';
		$dl_video = '';

		foreach ($mic_xx as $mic_v){
			if(empty($xxmic) && $mic_v['xxcz']==1 && $mic_v['xxcz_open']==1 ){
				$xxmic='/static/misc/'.$mic_v['mp3_lj'];
				$xxcz_class = intval( $mic_v['xxcz_class'] );
			}
			if(empty($xsmic) && $mic_v['xscz']==1 && $mic_v['xscz_open']==1 ){
				$xsmic='/static/misc/'.$mic_v['mp3_lj'];
				$xscz_class = intval( $mic_v['xscz_class'] );
			}
			if(empty($txmic) && $mic_v['tx']==1 &&$mic_v['tx_open']==1 ){
				$txmic='/static/misc/'.$mic_v['mp3_lj'];
				$tx_class = intval( $mic_v['tx_class'] );
			}
			if( 1==$mic_v['dl_open'] ){
				$dlmic='/static/misc/'.$mic_v['mp3_lj'];
				$dl_class = intval( $mic_v['dl_class'] );
			}
		}
		if($xxmic != ''){
			$where = 'czclass=2 and zt=0';
			$mic = SystemSet::name('chongzhi_list')->where($where)->find();
			if( !empty($mic) ){
				$xxcz_video = "<audio autoplay='false' hidden=true src='{$xxmic}'/>";
			}
		}
		if($xsmic != ''){
			$where = 'czclass=1 and zt=0';
			$mic=SystemSet::name('chongzhi_list')->where($where)->find();
			if( !empty($mic) ){
				$xscz_video = "<audio autoplay='false' hidden=true src='{$xsmic}'/>";
			}
		}
		if($txmic != ''){
			$where = 'zt<1 and ifck<1';
			$mic = SystemSet::name('tixian_list')->where($where)->find();
			if( !empty($mic) ){
				$tx_video = "<audio autoplay='false' hidden=true src='{$txmic}'/>";
			}
		}
		if( $dlmic!='' ){
			$mic = SystemSet::name('username')->where(['dlshstatus'=>1,'swzh'=>0])->find();
			if( !empty($mic) ){
				$dl_video = "<audio autoplay='false' hidden=true src='{$dlmic}'/>";
			}
		}
		$ret = array();
		if( !empty($xxcz_video) && $xxcz_class > 0 ){
			$ret['xx'] = array($xxcz_class=>$xxcz_video);
		}
		if( !empty($xscz_video) && $xscz_class > 0 ){
			$ret['xs'] = array($xscz_class=>$xscz_video);
		}
		if( !empty($tx_video) && $tx_class > 0 ){
			$ret['tx'] = array($tx_class=>$tx_video);
		}
		if( !empty($dl_video) && $dl_class>0 ){
			$ret['dl'] = array($dl_class=>$dl_video);
		}
		if(!empty($ret)){
			return json_encode($ret);
		}
	}
}